local AddAction = AddAction
local AddComponentAction = AddComponentAction
local AddStategraphActionHandler = AddStategraphActionHandler
GLOBAL.setfenv(1, GLOBAL)

local UpvalueUtil = require("utils/upvalueutil")

if not rawget(_G, "HotReloading") then
    local ACTIONS = {
        SUICIDE = Action({ priority=2, instant=true }),
    }

    for name, action in pairs(ACTIONS) do
        action.id = name
        action.str = STRINGS.ACTIONS[name] or name
        AddAction(action)
    end
end

ACTIONS.SUICIDE.fn = function(act)
    if act.invobject and act.invobject.Suicide then
        act.invobject:Suicide(act.doer)
    end

	return true
end

AddComponentAction("INVENTORY", "inventoryitem", function(inst, doer, actions, right)
	if inst:HasTag("suicidal") then
        table.insert(actions, ACTIONS.SUICIDE)
    end
end)

local COMPONENT_ACTIONS = UpvalueUtil.GetUpvalue(EntityScript.CollectActions, "COMPONENT_ACTIONS")
local SCENE = COMPONENT_ACTIONS.SCENE
local USEITEM = COMPONENT_ACTIONS.USEITEM
local POINT = COMPONENT_ACTIONS.POINT
local EQUIPPED = COMPONENT_ACTIONS.EQUIPPED
local INVENTORY = COMPONENT_ACTIONS.INVENTORY
